package com.zjj.learn.javaplus.pkg03.demo304;

public class TestDemo305_4 {

    public static void main(String[] args) {
        //使用多态创建狗和猫
        Animal dog = new Dog();
        Animal cat = new Cat();

        dog.eat();
        cat.eat();

        if (dog instanceof Dog) {
            Dog dog1 = (Dog) dog;
            dog1.lookHome();
        }
        if (cat instanceof Cat) {
            Cat cat1 = (Cat) cat;
            cat1.catchMouse();
        }
    }
}
